import VueRouter from 'vue-router'

import Login from '../pages/Login'
import Register from '../pages/Register'
import Reset from '../pages/Reset'
import UserIndex from '../pages/UserIndex'
import ManagerIndex from '../pages/ManagerIndex'
import Receive from '../pages/Receive'
import Send from '../pages/Send'
import PeopleList from '../pages/PeopleList'
import ReceiveItem from '../pages/ReceiveItem'
import SendItem from '../pages/SendItem'
import ChangePsd from '../pages/ChangePsd'
import Address from '../pages/Address'
import Edit from '../pages/Edit'
import AddAddress from '../pages/AddAddress'
import Order from '../pages/Order'
import CarList from '../pages/CarList'
import List from '../pages/List'
import ListItem from '../pages/ListItem'
import Distribution from '../pages/Distribution'
import DistributionDetail from '../pages/DistributionDetail'

export default new VueRouter({
    routes:[
        {
            path:'',
            redirect:'/login'
        },
        {
            path:'/login',
            component:Login
        },
        {
            path:'/register',
            component:Register
        },
        {
            path:'/reset',
            component:Reset
        },
        {
            path:'/userIndex',
            component:UserIndex,
            children:[
                {
                    path:'',
                    component:Receive,
                },
                {
                    path:'receive',
                    name:'shouhuo',
                    component:Receive,
                },
                {
                    path:'receiveItem',
                    name:'shouhuoxinxi',
                    component:ReceiveItem,
                    props($route){
                        return {id:$route.query.id}
                    }
                },
                {
                    path:'send',
                    name:'fahuo',
                    component:Send,
                },
                {
                    path:'sendItem',
                    name:'fahuoxinxi',
                    component:SendItem,
                    props($route){
                        return {id:$route.query.id}
                    }
                },
                {
                    path:'changePsd',
                    name:'gaimima',
                    component:ChangePsd
                },
                {
                    path:'address',
                    name:'dizhi',
                    component:Address
                    // props($route){
                    //     return {address:$route.query.address,name:$route.query.name,phone:$route.query.phone,acity:$route.query.acity}
                    // }
                },
                {
                    path:'edit',
                    name:'bianji',
                    component:Edit,
                    props($route){
                        return {id:$route.query.id}
                    }
                },
                {
                    path:'addAddress',
                    name:'tianjiadizhi',
                    component:AddAddress
                },
                {
                    path:'order',
                    name:'tuoyundan',
                    component:Order,
                }
            ]
        },
        {
            path:'/managerIndex',
            component:ManagerIndex,
            children:[
                {
                    path:'',
                    component:PeopleList
                },
                {
                    path:'peopleList',
                    name:'yuangong',
                    component:PeopleList
                },
                {
                    path:'carList',
                    name:'cheliang',
                    component:CarList
                },
                {
                    path:'list',
                    name:'dingdan',
                    component:List
                },
                {
                    path:'listItem',
                    name:'xiangqing',
                    component:ListItem,
                    props($route){
                        return {id:$route.query.id}
                    }
                },
                {
                    path:'distribution',
                    name:'fenpei',
                    component:Distribution
                },
                {
                    path:'distributionDetail',
                    name:'fenpeixiangqing',
                    component:DistributionDetail,
                    props($route){
                        return {id:$route.query.id}
                    }
                }
            ]
        }
    ]
    
})

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
};
